let table = [10]

function randomGenerateTable() {
  let alphabet = 'abcdefghijklmnopqrstuvwxyz'
  for (let i = 0; i < 10; i++) {
    table[i] = alphabet[randInt(26) - 1]
    // console.log(table[i] + randInt(26))
  }
}

function encrypt(s) {
  s = s.toString()
  let res = []
  for (let i = 0; i < s.length; i++) {
    // console.log(table[i])

    res[i] = table[(s[i].charCodeAt() + 2) % 10]
    // console.log((s[i].charCodeAt() + 2) % 10)
    let idx = s[i].charCodeAt() + 2
    // console.log(table[idx % 10])
    res[i] = table[idx % 10]
    // console.log(res[i])
  }
  return res.join('')
}

function getTable() {
  return table.join('')
}

function randInt(max) {
  return Math.floor(Math.random() * max) + 1
}

exports.encrypt = encrypt
exports.randomGenerateTable = randomGenerateTable
exports.getTable = getTable
